package com.leaf.u_spring.chapter04;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

/**
 * 演出效果 
 * 创建环绕通知
 * 
 */
@Aspect
public class Audience3 {

	/**
	 * 定义命名的切点
	 */
	@Pointcut("execution(** com.leaf.u_spring.chapter04.Performance.perform(..))")
	public void performance(){}
	
	/**
	 * 环绕通知方法
	 */
	@Around("performance())")
	public void watchPerformance(ProceedingJoinPoint jp){
		try {
			System.out.println("silence Cell Phones");
			System.out.println("taking seates");
			//不调用proceed方法，通知会阻塞对被通知方法的调用
			jp.proceed();
			System.out.println("CLAP CLAP CLAP!!!");
		} catch (Throwable e) {
			System.out.println("Demanding a refund");
		}
	}
	
}
